package com.ljh.account.service;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ljh.account.dao.Expense;

import com.ljh.account.dao.Resp.ExpenseResp;
import com.ljh.account.mapper.ExpenseMapper;
import org.apache.ibatis.annotations.Lang;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import java.math.BigDecimal;
import java.util.List;

@Service
public class ExpenseService {
    @Autowired
    private ExpenseMapper expenseMapper;

    public PageInfo getExpensesWithFilter(Long userId, Integer categoryId, Integer bankAccountId, BigDecimal minAmount, BigDecimal maxAmount,int page,int size) {
        PageHelper.startPage(page, size);
        List<ExpenseResp> list = expenseMapper.getExpensesWithFilter(userId, categoryId, bankAccountId, minAmount, maxAmount);
        return new PageInfo(list);
    }

    public ExpenseResp getExpenseById(int id) {
        return expenseMapper.getExpenseById(id);
    }

    public void addExpense(Expense expense) {
        expenseMapper.insertExpense(expense);
    }

    public void updateExpense(Expense expense) {
        expenseMapper.updateExpense(expense);
    }

    public void deleteExpense(Long id) {
        expenseMapper.deleteExpense(id);
    }
}
